/**
 *
 * 连续飞行
 * @param     navigationPath  漫游路径
 * @param     viewer          Mars3d实例对象
 *
 */


export function flyLoop(navigationPath, viewer = window.viewer) {
    const positions = navigationPath.positions
    let count = 0
    fly()
    function fly (){
        if (count >= positions.length) {
            return;
        }
        const position = positions[count];
        viewer.camera.flyTo({
            destination: Cesium.Cartesian3.fromDegrees(...position.cameraPose.position),
            orientation: {
                heading: position.cameraPose.heading,
                pitch: position.cameraPose.pitch,
                roll: position.cameraPose.roll
            },
            maximumHeight: 0,
            complete: function() {
                fly();
            }
        });
        count++;
    }
}